package gui.visu.components;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;

import javax.swing.JPanel;

/**
 * @author Charles Perin
 * 29 mars 2011
 * LIMSI - INRIA Rennes
 * charles.perin@free.fr
 *
 */
public class MoviePanel extends JPanel{

	/**
	 * 
	 */
	private static final long serialVersionUID = -1076362383457232626L;

	private BufferedImage image;
	private double ratio;


	public MoviePanel(){
		super();
	}

	public void change(BufferedImage image) {
		if (image!=null) {
			this.image = image;
			ratio = (double)image.getWidth()/image.getHeight();  
			repaint();
		}
		else{
			System.err.println("Movie panel : image nulle");
		}
	}


	@Override
	protected void paintComponent(Graphics g){
		g.setColor(Color.BLACK);
		g.fillRect(0, 0, this.getWidth(), this.getHeight());
		if(image != null){
			g.drawImage(image, 10, (this.getHeight()-image.getHeight())/4, this.getWidth()-20, (int)(this.getWidth()/ratio), null);  
		}

	}
}
